package com.hsc.yalebao.newui;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.handmark.pulltorefresh.library.ILoadingLayout;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.hsc.yalebao.adapter.ZoushituAdapter;
import com.hsc.yalebao.base.ActivityStack;
import com.hsc.yalebao.base.BaseActivity;
import com.hsc.yalebao.base.CustomApplication;
import com.hsc.yalebao.base.MainActivity;
import com.hsc.yalebao.http.AppConstants;
import com.hsc.yalebao.http.RequestNet;
import com.hsc.yalebao.model.IssueListBaseBean;
import com.hsc.yalebao.model.IssueListBean;
import com.hsc.yalebao.tools.UiUtil;
import com.hsc.yalebao.weight.LogUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import okhttp3.Call;

public class UpNewZoushituActivity extends BaseActivity
{
  public static final String TAG = "ZoushituActivity";
  Context context;
  private View emptyView;
  private boolean isEnd = false;
  private ArrayList<IssueListBaseBean> issueListBaseBeanList;
  private ImageView iv_title_right;
  private String lotteryid;
  private PullToRefreshListView lv_zoushitu;
  View.OnClickListener onClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      switch (paramAnonymousView.getId())
      {
      default:
        return;
      case 2131099699:
      }
      CustomApplication.app.finishActivity(UpNewZoushituActivity.this);
    }
  };
  private int page = 1;
  private TextView tv_tishi;
  private ZoushituAdapter zoushituAdapter;

  private void getNearlyIssueResultList(final boolean paramBoolean)
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("lotteryid", this.lotteryid);
    localHashMap.put("page", this.page);
    localHashMap.put("Pagesize", "15");
    LogUtils.d("ZoushituActivity", "URL:" + AppConstants.URL_GET_ISSUE_CHART_LIST);
    RequestNet.get(this.context, AppConstants.URL_GET_ISSUE_CHART_LIST, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        UpNewZoushituActivity.this.lv_zoushitu.onRefreshComplete();
        LogUtils.e("ZoushituActivity", "获取失败,getNearlyIssueResultList-result:" + paramAnonymousException);
        UpNewZoushituActivity.this.lv_zoushitu.setEmptyView(UpNewZoushituActivity.this.emptyView);
        UpNewZoushituActivity.this.tv_tishi.setText("获取失败");
      }

      public void onResponse(String paramAnonymousString)
      {
        UpNewZoushituActivity.this.lv_zoushitu.onRefreshComplete();
        if ((paramAnonymousString == null) || ("".equals(paramAnonymousString)))
        {
          LogUtils.e("ZoushituActivity", "result:" + paramAnonymousString);
          UpNewZoushituActivity.this.tv_tishi.setText("获取失败");
        }
        IssueListBean localIssueListBean;
        do
        {
          return;
          Gson localGson = new Gson();
          try
          {
            localIssueListBean = (IssueListBean)localGson.fromJson(paramAnonymousString, IssueListBean.class);
            if (localIssueListBean == null)
            {
              LogUtils.e("ZoushituActivity", "getCurrSecond-issueTimeBean == null，获取失败");
              UpNewZoushituActivity.this.tv_tishi.setText("获取失败");
              return;
            }
          }
          catch (Exception localException)
          {
            while (true)
            {
              localException.printStackTrace();
              localIssueListBean = null;
            }
            if (localIssueListBean.getFlag() == 0)
            {
              UpNewZoushituActivity.activityStack.backToMain(MainActivity.class, UpNewZoushituActivity.this.context);
              return;
            }
            System.out.println("获取flag=" + localIssueListBean.getFlag());
            if (localIssueListBean.getFlag() == 0)
            {
              UiUtil.showToast(UpNewZoushituActivity.this.context, localIssueListBean.getMsg());
              LogUtils.e("ZoushituActivity", "获取最近10期开奖结果getNearlyIssueResultList():" + localIssueListBean.getMsg());
              UpNewZoushituActivity.this.tv_tishi.setText("获取失败");
              return;
            }
            if (localIssueListBean.getFlag() == -2)
            {
              UpNewZoushituActivity.this.showDownWireDialog();
              return;
            }
            if (localIssueListBean.getFlag() == -3)
            {
              UpNewZoushituActivity.this.ShowFengjinDialog();
              return;
            }
          }
        }
        while (localIssueListBean.getFlag() != 1);
        if (localIssueListBean.result == null)
        {
          System.out.println("服务器返回数据错误=" + localIssueListBean.result + "=null");
          return;
        }
        if (paramBoolean)
          if ((UpNewZoushituActivity.this.issueListBaseBeanList != null) && (localIssueListBean.result.size() > 0))
          {
            UpNewZoushituActivity.this.issueListBaseBeanList.addAll(localIssueListBean.getResult());
            if (UpNewZoushituActivity.this.issueListBaseBeanList.size() >= 10)
              break label453;
            UpNewZoushituActivity.this.isEnd = true;
          }
        for (int i = 0; ; i++)
        {
          if (i >= UpNewZoushituActivity.this.issueListBaseBeanList.size())
          {
            if (UpNewZoushituActivity.this.zoushituAdapter == null)
              break label524;
            UpNewZoushituActivity.this.zoushituAdapter.setData(UpNewZoushituActivity.this.issueListBaseBeanList);
            UpNewZoushituActivity.this.zoushituAdapter.notifyDataSetChanged();
            System.out.println("更新数据");
            return;
            label453: UpNewZoushituActivity.this.isEnd = false;
            break;
            UpNewZoushituActivity.this.issueListBaseBeanList = localIssueListBean.getResult();
            break;
          }
          System.out.println("RealWin" + ((IssueListBaseBean)UpNewZoushituActivity.this.issueListBaseBeanList.get(i)).RealWin);
        }
        label524: UpNewZoushituActivity.this.zoushituAdapter = new ZoushituAdapter(UpNewZoushituActivity.this.context, UpNewZoushituActivity.this.issueListBaseBeanList);
        UpNewZoushituActivity.this.lv_zoushitu.setAdapter(UpNewZoushituActivity.this.zoushituAdapter);
        System.out.println("第一次设置数据");
      }
    });
  }

  private void initData()
  {
    this.issueListBaseBeanList = new ArrayList();
    getNearlyIssueResultList(false);
  }

  private void initRefresh()
  {
    this.lv_zoushitu.setMode(PullToRefreshBase.Mode.BOTH);
    this.lv_zoushitu.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener()
    {
      public void onRefresh(PullToRefreshBase<ListView> paramAnonymousPullToRefreshBase)
      {
        String str = DateUtils.formatDateTime(UpNewZoushituActivity.this.getApplicationContext(), System.currentTimeMillis(), 524305);
        paramAnonymousPullToRefreshBase.getLoadingLayoutProxy().setLastUpdatedLabel(str);
        if (UpNewZoushituActivity.this.lv_zoushitu.isHeaderShown())
        {
          LogUtils.e("ZoushituActivity", "mPullRefreshListView刷新");
          UpNewZoushituActivity.this.refeshList();
          return;
        }
        LogUtils.e("ZoushituActivity", "mPullRefreshListView加载");
        if (UpNewZoushituActivity.this.isEnd)
          UiUtil.showToast(UpNewZoushituActivity.this.context, "暂无更多数据");
        UpNewZoushituActivity localUpNewZoushituActivity = UpNewZoushituActivity.this;
        localUpNewZoushituActivity.page = (1 + localUpNewZoushituActivity.page);
        UpNewZoushituActivity.this.getMoreList();
      }
    });
  }

  private void initView()
  {
    this.lv_zoushitu = ((PullToRefreshListView)findViewById(2131100024));
    this.emptyView = LayoutInflater.from(this.context).inflate(2130903139, null);
    this.tv_tishi = ((TextView)this.emptyView.findViewById(2131100053));
    this.tv_tishi.setText("获取中...");
    this.lv_zoushitu.setEmptyView(this.emptyView);
    setTitle(8, 0, 2130837809, "开奖走势", 0, 8, 8, 0, true);
    initRefresh();
  }

  protected void getMoreList()
  {
    getNearlyIssueResultList(true);
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903100);
    this.context = this;
    this.lotteryid = getIntent().getStringExtra("lotteryid");
    initView();
    initData();
  }

  protected void refeshList()
  {
    this.page = 1;
    getNearlyIssueResultList(false);
  }

  @SuppressLint({"NewApi"})
  public void setTitle(int paramInt1, int paramInt2, int paramInt3, String paramString, int paramInt4, int paramInt5, int paramInt6, int paramInt7, boolean paramBoolean)
  {
    View localView = findViewById(2131099716);
    if (paramBoolean)
      localView.setVisibility(0);
    while (true)
    {
      TextView localTextView1 = (TextView)localView.findViewById(2131099701);
      localTextView1.setText(paramString);
      localTextView1.setTextSize(22.0F);
      ((TextView)localView.findViewById(2131099700)).setVisibility(paramInt1);
      ImageView localImageView = (ImageView)localView.findViewById(2131099699);
      localImageView.setVisibility(paramInt2);
      localImageView.setOnClickListener(this.onClickListener);
      localImageView.setImageResource(paramInt3);
      TextView localTextView2 = (TextView)localView.findViewById(2131099702);
      localTextView2.setVisibility(paramInt5);
      localTextView2.setOnClickListener(this.onClickListener);
      ((ImageView)localView.findViewById(2131099703)).setVisibility(8);
      this.iv_title_right = ((ImageView)localView.findViewById(2131099704));
      this.iv_title_right.setVisibility(paramInt6);
      this.iv_title_right.setOnClickListener(this.onClickListener);
      this.iv_title_right.setImageResource(paramInt7);
      return;
      localView.setVisibility(8);
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.newui.UpNewZoushituActivity
 * JD-Core Version:    0.6.2
 */